$(() => {
    $.get('/kobe/selectAdminInfo.do', success);
});

function success(resp) {
    $('#admin1').val(resp.adminCode);
    $('#role').val(resp.rNames);
    $('#name').val(resp.name);
    $('#telephone').val(resp.telephone);
    $('#email').val(resp.email);
    $('#enrolldate').val(resp.enrolldate);
}

//保存成功的提示信息
function showResult() {
    var adminInfo = {
        'adminCode': $('#admin1').val(),
        'name': $('#name').val(),
        'telephone': $('#telephone').val(),
        'email': $('#email').val()
    };
    var settings = {
        url: '/kobe/updateAdminInfo.do',
        method: 'post',
        contentType: 'application/json;charset=UTF-8',
        data: JSON.stringify(adminInfo),
        dataType: 'json'
    }
    $.ajax(settings).done(respModify);
}

function respModify(resp) {
    if (resp) {
        $('#save_result_info').attr('class', 'save_success').text('保存成功!');
        showResultDiv(true);
        window.setTimeout("showResultDiv(false);", 3000);
    } else {
        $('#save_result_info').attr('class', 'save_fail').text('保存失败!');
        showResultDiv(true);
        window.setTimeout("showResultDiv(false);", 3000);
    }
    setTimeout("location.reload(true)", 3000);
}

function showResultDiv(flag) {
    var divResult = document.getElementById("save_result_info");
    if (flag)
        divResult.style.display = "block";
    else
        divResult.style.display = "none";
}